package com.sumainfor.pc.dev.service.impl;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.dev.dao.QuestionMapper;
import com.sumainfor.pc.dev.service.QuestionMapperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class QuestionMapperServiceImpl implements QuestionMapperService {


    @Autowired
    QuestionMapper questionMapper;

    /**
     * 查询密保问题
     *
     * @return
     */
    @Override
    public JsonResult getquestion() {
        JsonResult result = new JsonResult();
        result.put(questionMapper.getquestion());
        return result;
    }

    @Override
    public JsonResult getMesId(Map<String,Object> params) {
        JsonResult result = new JsonResult();
        result.put(questionMapper.getMesId(params));
        return result;
    }

    @Override
    public JsonResult getMessageById(List<Map<String, Object>> params) {
        JsonResult result = new JsonResult();

        List<Map<String, Object>> dataList = new ArrayList<Map<String, Object>>();
        for (Map<String, Object> param : params) {
            Map<String, Object> para = questionMapper.getMessageById(param);
            Map<String, Object> datamap = new HashMap<String, Object>();
            datamap.putAll(param);
            datamap.put("MesTitle", para.get("MesTitle"));
            datamap.put("MesFile", para.get("MesFile"));
            dataList.add(datamap);
        }
        result.put(dataList);
        return result;
    }

    @Override
    public JsonResult getMessageinfoById(Map<String, Object> params) {
        JsonResult result = new JsonResult();
        result.put(questionMapper.getMessageById(params));
        return result;
    }
}
